import { PageConfig } from 'next';
import an48 from '@mmstudio/an000048';
import anylogger from 'anylogger';
import '@mmstudio/an000042';
import an49 from '@mmstudio/an000049';
import a005 from '../../../atoms/getuser';

const logger = anylogger('pages/api/account/go.api');

export type Result = {
	ok: true;
} | {
	ok: false;
	message: string;
};

export type Message = {

}

export type Query = {

}

/**
 * 登陆成功跳转页面
 */
const handler = an48<Result>();

handler.get(async (req, res) => {
	try {
		const user = await a005(req);
		if (!user) {
			logger.error('无法获取用户信息,跳转到登陆页面');
			res.redirect('/public/login');
			return;
		}
		//跳转简介
		res.redirect('/introduction');
	} catch (error) {
		logger.error(error);
		res.status(200).json({ ok: false, message: (error as Error).message });
	}
});

export const config = {} as PageConfig;

export default handler;
